using System;
using System.Collections.Generic;
using System.Linq;
using Granite.Commons.Collections;

namespace LeadTracker.Models
{
	public class LeadCollection : ImprovedObservableCollection<LeadModel>
	{
		public LeadCollection() { }

		public LeadCollection(List<LeadModel> list) : base(list) { }
		
		public LeadCollection(IEnumerable<LeadModel> collection) : base(collection) { }

		public LeadCollection(IEnumerable<IDictionary<string, object>> table)
		{
			Add(table);
		}

		public void Add(IEnumerable<IDictionary<string, object>> table)
		{
			foreach (var item in table)
				Add(new LeadModel(item));
		}

		public LeadModel FindKey(int leadKey)
		{
			return this.FirstOrDefault(e => e.LeadKey == leadKey);
		}

	}
}

